//
//  UIBarButtonItem+Extension.m
//  DigitalCampus
//
//  Created by zsj1992 on 16/6/7.
//  Copyright © 2016年 刘占宇. All rights reserved.
//

#import "UIBarButtonItem+Extension.h"

@implementation UIBarButtonItem (Extension)

+(instancetype)creatItemWithImageName:(NSString *)imageName selectedImage:(NSString *)imageNameSel andTarget:(id)target action:(SEL)action title:(NSString * )title{

    UIButton * btn = [[UIButton alloc]init];
   
    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:imageNameSel] forState:UIControlStateSelected];
    
    btn.frame = CGRectMake(0, 0, 40, 40);

    [btn setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    
    [btn setTitle:title forState:UIControlStateNormal];
    //设置btn的文字
    
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];

    UIBarButtonItem * item = [[UIBarButtonItem alloc]initWithCustomView:btn];
    
    return item;
}
@end

